window.addEventListener('load', () => {
    //获取变量
    const uname = document.querySelector('[type="text"]')
    const upwd = document.querySelector('[type="password"]')
    const btn = document.querySelector('.submit')
    var username = cookie('username')
    var userpwd = cookie('pwd')
        // 点击事件
    btn.onclick = function() {
        //阻止默认行为
        window.event.preventDefault()
        if (uname.value !== username && upwd.value !== userpwd) {
            alert('用户名或者密码有误，请重新输入')
            return false
        }
        setcookie('uname', uname.value)
        setcookie('upass', upwd.value)
        alert('登陆成功！！！')
        location.href = './list.html'
    }
})